#coding=utf-8
'''
3.5. Packing and Unpacking Large Integers from Bytes
int.from_bytes()
int.to_bytes()
'''
data = b'\x00\x124V\x00x\x90\xab\x00\xcd\xef\x01\x00#\x004'
print(len(data))
# print(int.from_bytes(data, 'little'))

x = 94522842520747284487117727783387188
# print(x.to_bytes(16, 'big'))  # 16个元素，128位字长
# print(x.to_bytes(16, 'little'))

print(data)
import struct
hi, lo = struct.unpack('>QQ', data)
print(hi << 64) * lo

x = 523 ** 23
print(x)
print(x.bit_length())
nbytes, rem = divmod(x.bit_length(), 8)
if rem:
    nbytes += 1
print(x.to_bytes(nbytes, 'little'))